<?php
namespace app\house\controller;
use app\AdminRest;
use think\App;
use think\Request;
use app\house\model\AdminBanner as banner_model;
class AdminBanner extends AdminRest
{

    protected $model;
    public function __construct(App $app) {
        parent::__construct($app);
        $this->model = new banner_model();
    }

    /**
     * 房产banner列表
     */
    public function bannerList(){
        $input= $this->_param;
        $data = $this->model->bannerList(['uniacid'=>$this->_uniacid],$input['limit']);
        return $this->success($data);
    }

    /**
     *
     * 添加banner分类
     */
    public function bannerAdd(){
        $input = $this->_input;
        $input['uniacid'] = $this->_uniacid;
        if(!empty($input['path'])){
            $input['path'] = implode(',',$input['path']);
        }
        $res = $this->model->bannerAdd($input);
        return $this->success($res);
    }

    /**
     *
     * 编辑banner分类
     */
    public function bannerUpdate(){
        $input = $this->_input;
        if(count($input)>1){
            if(!empty($input['path'])){
                $input['path'] = implode(',',$input['path']);
            }
            $data = $this->model->bannerUpdate(['id'=>$input['id']],$input);
        }else{
            $data = $this->model->bannerInfo(['id'=>$input['id']]);
        }
        return $this->success($data);
    }




}
